<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>confirm在table中的使用</title>
    <style>

        .danger {
             background-color: red;
        }
    </style>
</head>
<body>


      <table>
          <thead>
               <tr>
                   <td style="display: none">1</td>
                   <th>编号</th>
                   <th>姓名</th>
                   <th>部门</th>
                   <th>操作</th>
               </tr>
          </thead>

          <tbody>
             <tr>
                 <td>No001</td>
                 <td>M</td>
                 <td>Dev</td>
                 <td>
                     <button>编辑</button>
                     <button>离职</button>
                 </td>
             </tr>
             <tr>
                 <td style="display: none">2</td>
                 <td>No001</td>
                 <td>M</td>
                 <td>Dev</td>
                 <td>
                     <button>编辑</button>
                     <button>离职</button>
                 </td>

             </tr>
             <tr>
                 <td style="display: none">3</td>
                 <td>No001</td>
                 <td>M</td>
                 <td>Dev</td>
                 <td>
                     <button>编辑</button>
                     <button id="btnQuit">离职</button>
                 </td>
             </tr>

          </tbody>
      </table>
</body>
<script>
    var btnQuit = document.getElementById('btnQuit');


    btnQuit.onclick = function (){

         if(confirm('确定对当前员工进行离职操作吗？')){


            // this.parentElement.style.backgroundColor = 'red';

            // this.parentElement.parentElement.style.backgroundColor = 'red';

             this.parentElement.parentElement.classList.add('danger');

             /**
              *  弹出alert 提示框
              *    你已经对 id 是 {id} 员工进行了离职操作
              *     {id} 代表 隐藏的td中的数字
              * */

            var empId= this.parentElement.parentElement.children[0].innerHTML;
            alert(empId);

            var trow =  this.parentElement.parentElement;
            trow.remove();


         }

    }

</script>
</html>